package main

import (
	"fmt"
	"github.com/astaxie/beego/logs"
	"logagent/kafka"
	"logagent/tailf"
)

func main()  {

	filename := "/home/cds/go/src/logagent/conf/log.conf"

	err := loadConfig("ini",filename)
	if err != nil {
		fmt.Println("load conf failed,err :",err)
		panic("load conf failed")
		return
	}
	fmt.Println("logs path:",appConfig.logPath)
	fmt.Println("logs level:",appConfig.logLevel)

	err = initLogger()
	if err != nil{
		fmt.Println("init conf failed,err:",err)
		return
	}
	 logs.Debug("initialize success")

	err = tailf.InitTail(appConfig.collect,appConfig.chansize)
	if err != nil {
		logs.Debug("initialize  tail failed")
		return
	}

	err = kafka.InitKafka(appConfig.kafkaconf)
	if err != nil {
		logs.Error("kafka init failed ,err:",err)
		return
	}
/*go func() {
	var count int
	for  {
		count++
		logs.Debug("test for logger %d",count)
		time.Sleep(time.Millisecond*1000)
	}
}()*/

	err = runserver()
	if err != nil {
		logs.Error("serverRun failed ,err:",err)
		return
	}
	logs.Info("program exited")

}